<template>
<div>
  <mavon-editor v-model="value" @change="changeData" @imgAdd="addImage" @save="preserve"/>
  <el-button type="primary" @click="preserve()">保存</el-button>
  <mavon-editor
        class="md"
        v-model="markdownValue"
        :subfield="false"
        :defaultOpen="'preview'"
        :toolbarsFlag="false"
        :editable="false"
        :scrollStyle="true"
        :ishljs="true"
        :imageFilter="myFilter"
      />
<article class="markdown-body"  v-html="markdownValue" ></article>
</div>

</template>

<script>
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  data() {
    return {
      markdownValue:"",
      value:""
    }
  },
  methods:{
    changeData(val,val2){
      console.log(val2)
      this.markdownValue = val2
      val
    },
    addImage(val,val2){
      val
      val2
    },
    preserve(){
      console.log(this.value);//md类型，一般用这个，获取的时候直接用mavonEditor渲染就行了
      console.log(document.querySelector(".v-note-show").innerHTML);
      this.markdownValue=this.value;
    },
    myFilter(){
      return false
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
